using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ItemTrigger : MonoBehaviour
{
    void Start()
    {
    }

    void Update()
    {
        
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (transform.parent != null)
        {
            if (transform.parent.gameObject.TryGetComponent(out ItemTriggerReceiver receiver))
            {
                receiver.OnTriggerEnter2D(collision);
            }
        }
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (transform.parent != null)
        {
            if (transform.parent.gameObject.TryGetComponent(out ItemTriggerReceiver receiver))
            {
                receiver.OnCollisionEnter2D(collision);
            }
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (transform.parent != null)
        {
            if(transform.parent.gameObject.TryGetComponent(out ItemTriggerReceiver receiver))
            {
                receiver.OnTriggerExit2D(collision);
            }
        }
    }
}
